package com.infosys.test.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class BDManagement {

private final static String driver ="com.mysql.jdbc.Driver";	//para relacionar java con el conectar
private final static String host ="jdbc:mysql://localhost:9999/geoschema";	
private final static String usuario = "root";
private final static String psw ="hurtarte";

private Connection connection; //para hacer la conexion
private Statement statement; // para hacer las consultas en las bases de datos


public BDManagement(){
	try{
		Class.forName(driver);//se pasa el driver a este metodo de Class
		connection = DriverManager.getConnection(host,usuario,psw);
		statement = connection.createStatement();
		System.out.println("Conexion exitosa");
	}catch(Exception e){
	
	System.out.println("No se pudo hacer la conexion");
	}
}
public void showAll(){
	try{
		
		ResultSet rs= statement.executeQuery("SELECT * FROM PERSONAS");
		while(rs.next()){
		System.out.println(rs.getString(1)+ "|"+rs.getString(2)+"|"+rs.getString(3));
		
		}
		
	}catch(Exception e){
		System.out.println("Error al realizar la consulta");
	}
	
	
}

public Statement getState(){
	return statement;
}



}
